/*     */ package dm.jdbc.driver;
/*     */ 
/*     */ import dm.jdbc.dataConvertion.Convertion;
/*     */ import dm.jdbc.dbaccess.DBError;
/*     */ import dm.jdbc.dbaccess.DmMsgSend;
/*     */ import dm.jdbc.desc.ParameterDesc;
/*     */ import java.math.BigDecimal;
/*     */ import java.sql.SQLException;
/*     */ 
/*     */ public class DmBigDecBinder
/*     */   extends DmBinder
/*     */ {
/*     */   public DmBigDecBinder(DmdbPreparedStatement_bs pstmt)
/*     */   {
/*  15 */     super(pstmt);
/*     */   }
/*     */   
/*     */   void init() {
/*  19 */     this.recDType = 9;
/*  20 */     this.recPrec = 0;
/*  21 */     this.recScale = 0;
/*     */   }
/*     */   
/*     */   void checkType(int icol, boolean forBatch) throws SQLException {
/*  25 */     if (this.m_checkType) {
/*  26 */       return;
/*     */     }
/*  28 */     this.m_checkType = true;
/*     */     
/*  30 */     if (this.paramsDesc == null) {
/*  31 */       this.paramsDesc = this.pstmt.getParamsDesc();
/*     */     }
/*  33 */     byte typeFlag = this.paramsDesc[icol].getTypeFlag();
/*  34 */     int dType = this.paramsDesc[icol].getDType();
/*  35 */     int prec = this.paramsDesc[icol].getPrec();
/*  36 */     int scale = this.paramsDesc[icol].getScale();
/*  37 */     byte ioType = this.paramsDesc[icol].getIOType();
/*     */     
/*  39 */     if ((ioType != 1) && 
/*  40 */       (typeFlag != 1) && 
/*  41 */       (dType != 11) && 
/*  42 */       (dType != 10)) {
/*  43 */       this.destDType = this.recDType;
/*  44 */       this.destPrec = this.recPrec;
/*  45 */       this.destScale = this.recScale;
/*     */     } else {
/*  47 */       this.destDType = dType;
/*  48 */       this.destPrec = prec;
/*  49 */       this.destScale = scale;
/*     */     }
/*     */     
/*  52 */     this.destIoType = ioType;
/*  53 */     this.srcScale = scale;
/*     */   }
/*     */   
/*     */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*     */   {
/*  58 */     BigDecimal x = ((BigDecimal[])this.pstmt.m_paramObjects[icol])[irow];
/*  59 */     String serverEncoding = this.pstmt.connection.getServerEncoding();
/*  60 */     byte[] ret = toDbBytes(x, this.destDType, this.destPrec, this.destScale, 
/*  61 */       serverEncoding);
/*     */     
/*  63 */     return msg.appendBytesWithLen2(ret, 0, ret.length);
/*     */   }
/*     */   
/*     */   public static byte[] toDbBytes(BigDecimal x, int destDType, int destPrec, int destScale, String serverEncoding) throws SQLException
/*     */   {
/*  68 */     byte[] ret = null;
/*  69 */     switch (destDType) {
/*     */     case 9: 
/*     */     case 24: 
/*  72 */       ret = Convertion.BigDecimalToByteArray(String.valueOf(x), destPrec, 
/*  73 */         destScale);
/*  74 */       break;
/*     */     case 3: 
/*     */     case 13: 
/*  77 */       boolean b_v = x.compareTo(new BigDecimal(0.0D)) != 0;
/*  78 */       ret = Convertion.booleanToByteArray(b_v);
/*  79 */       break;
/*     */     case 5: 
/*  81 */       ret = Convertion.byteToByteArray(x.byteValue());
/*  82 */       break;
/*     */     case 6: 
/*  84 */       ret = Convertion.shortToByteArray(x.shortValue());
/*  85 */       break;
/*     */     case 7: 
/*  87 */       ret = Convertion.IntToByteArray(x.intValue());
/*  88 */       break;
/*     */     case 8: 
/*  90 */       ret = Convertion.longToByteArray(x.longValue());
/*  91 */       break;
/*     */     case 10: 
/*  93 */       ret = Convertion.floatToByteArray(x.floatValue());
/*  94 */       break;
/*     */     case 11: 
/*  96 */       ret = Convertion.doubleToByteArray(x.doubleValue());
/*  97 */       break;
/*     */     case 0: 
/*     */     case 1: 
/* 100 */       ret = Convertion.String_char_2CType(String.valueOf(x), destPrec, 
/* 101 */         destDType, serverEncoding);
/* 102 */       break;
/*     */     case 2: 
/*     */     case 19: 
/* 105 */       ret = Convertion.String_varchar_2CType(String.valueOf(x), destPrec, 
/* 106 */         destDType, serverEncoding);
/* 107 */       break;
/*     */     case 4: case 12: case 14: case 15: case 16: case 17: 
/*     */     case 18: case 20: case 21: case 22: case 23: default: 
/* 110 */       DBError.throwSQLException(6007);
/*     */     }
/*     */     
/* 113 */     return ret;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmBigDecBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */